<div class="lib-edit">
    <div class="header" style="border:0;border-bottom:1px solid #dbdbdb;padding:12px;">
        <a href="javascript:void(0);" onclick="window.history.go(-1);">员工通道单图文编辑</a>
    </div>
    <div class="content">                
        <div class="preview" style="margin-right:-5px;">
            <div class="cell" style="border-left:0;">
                <div class="lib-title">
                    <span id="previewTitle" style="font-size:14px;text-align:center;display:block;"><{if $infoRow.info_title}><{$infoRow.info_title}><{else}>标题<{/if}> </span>
                    <p><{$today}></p>
                </div>
                <div class="cover">
                    <{if $infoRow.info_pic}>
                    <img src="../../data/image_c/<{$infoRow.info_pic}>" style="width:246px;"/>
                    <{else}>
                    <div class="img-default" style="line-height:136px;font-size:22px;"> 封面图片 </div>
                    <{/if}>
                </div>
            </div>
        </div>
        <div class="editor" style="width:550px;">
            <form id="text_form" method="post" action="single.php" onsubmit="javascript:return false;">
            <div class="cell cell-dark">
                <div class="form-rule form-rule-add">
                    <div class="form-group">
                        <label>标题<strong class="c-red">*</strong></label>
                        <input name="str[info_title]" type="text" class="form-control" value="<{$infoRow.info_title}>" id="actureTitle" />
                    </div>
                    <div class="form-group">
                        <label>封面
                            <input name="num[pic_showincontent]" type="checkbox" value="1" <{if $infoRow.pic_showincontent==1}>checked<{/if}> />
                            <span class="c-gray">
                                <span class="c-green">正文内显示</span>
                                （图片建议尺寸：<i style="color:red;font-style:normal;">540px*300px</i>）
                            </span>
                        </label>
                        <div class="fg-upload" onclick="up_img_fun()">
                            <input id="local-image" type="text" readonly class="form-control" style="padding-left:70px;">
                            <a href="javascript:void(0);" class="btn-upload"><i class="icons icons-upload"></i>上传</a>
                        </div>
                    </div>
                    <div class="form-group">
                        <label>简介</label>
                        <textarea name="str[info_desc]" class="form-control" style="height:150px;" /><{$infoRow.info_desc}></textarea>
                    </div>
                </div>
            </div>
            <div class="opt">
                <input type="hidden" name="a" value="add"/>
                <input type="hidden" name="num[id]" value="<{$infoRow.id}>"/>
                <input type="hidden" name="str[type]" value="ygtd"/>
                <input type="hidden" name="num[info_type]" value="2"/>
                <input type="hidden" name="str[info_pic]" id="info_pic" value="<{$infoRow.info_pic}>"/>
                <input type="button" class="btn btn-large btn-success" value="完成" id="saveBtn" onclick="save(this)" />
            </div>
            </form>
        </div>
    </div>
</div>

<!-- 上传图片开始 -->	
<link rel="stylesheet" type="text/css" href="../public/upimg/css/upimg.css" />
<script type="text/javascript" src="../public/upimg/upimg.js"></script>
<script type="text/javascript">
/**
 * up_img_fun(up_img_php) 执行上传的函数，微沟通图片上传的改版
 * @param string up_img_php 后台处理图片上传的文件，默认是'../info/upload.php'
 * 
 * up_img_notify(img_path) 上传回调函数
 * @param string img_path 返回的图片地址，图片仍放在/data/image_c/下
 */
function up_img_notify(img_path){
    $('#info_pic').val(img_path);
    $('.cover').html('<img src="../../data/image_c/'+img_path+'" style="width:246px;"/>');
}
</script>
<!-- 上传图片结束 -->

<script type="text/javascript">
$(function(){
    //标题预览
    $('#actureTitle').keyup(function(){
        $('#previewTitle').text($(this).val());
    });
});
//数据保存
function save(obj){
    if($("#actureTitle").val()==''){
        note_info('请填写标题',obj,'warn');return;
    }
    if($("#info_pic").val()==''){
        note_info('请上传封面图片',obj,'warn');return;
    }
    
    //敏感词过滤
    var matchStr,senseRow;
    var senseStr='';
    if('<{$senseRow}>'){
        senseRow=$.parseJSON('<{$senseRow}>');
        //简介
        $.each(senseRow,function(i,n){
            matchStr=$("textarea[name='str[info_desc]']").val().match(n);
            if(matchStr) senseStr+='&nbsp;'+matchStr+'&nbsp;';
        });
        if(senseStr){
            note_info('简介包含敏感词'+senseStr+'请更换',obj,'warn');return;
        }
        //标题
        matchStr='';senseStr='';
        $.each(senseRow,function(i,n){
            matchStr=$("#actureTitle").val().match(n);
            if(matchStr) senseStr+='&nbsp;'+matchStr+'&nbsp;';
        });
        if(senseStr){
            note_info('标题包含敏感词'+senseStr+'请更换',obj,'warn');return;
        }
    }
    
    $.post('fix.php',$('#text_form').serialize(),function(msg){
        msg=$.trim(msg);
        if(msg=='suc'){
            note_info('保存成功',obj);
        }else{
            note_info(msg,obj,'warn');
        }
    });
}
</script>